﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Demo</title>
    <!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
    <link href="//unpkg.com/layui@2.9.17/dist/css/layui.css" rel="stylesheet">
</head>
<body>
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">客户编号</label>
                <div class="layui-input-inline">
                    <input type="text" name="ClientCode" lay-verify="required" placeholder="请输入客户编号" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">客户名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="ClientName" lay-verify="required" placeholder="请输入客户名称" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">客户简称</label>
                <div class="layui-input-inline">
                    <input type="text" name="ClientNick" lay-verify="required" placeholder="请输入客户简称" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" style="width:auto">客户英文名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="ClientEn" lay-verify="required" placeholder="请输入客户英文名称" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">客户类型</label>
                <div class="layui-input-inline">
                    <select name="ClientType" lay-filter="aihao" lay-verify="required">
                        <option value="">请选择客户类型</option>
                        <option value="企业">企业</option>
                        <option value="个人">个人</option>
                    </select>
                </div>
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">客户简介</label>
            <div class="layui-input-block">
                <textarea name="ClientDesc" placeholder="请输入内容" class="layui-textarea"></textarea>
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">客户地址</label>
            <div class="layui-input-block">
                <textarea name="Address" placeholder="请输入内容" class="layui-textarea"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label" style="width:auto">客户官网地址</label>
                <div class="layui-input-inline">
                    <input type="text" name="Website" lay-verify="required" placeholder="请输入客户官网地址" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" style="width:auto">客户邮箱地址</label>
                <div class="layui-input-inline">
                    <input type="text" name="Email" lay-verify="required" placeholder="请输入客户邮箱地址" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">客户电话</label>
                <div class="layui-input-inline">
                    <input type="text" name="Tel" lay-verify="required" placeholder="请输入客户电话" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">客户LOGO</label>
                <div class="layui-input-inline">
                    <input type="text" name="ClientLogo" lay-verify="required" placeholder="请输入客户LOGO" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">联系人1</label>
                <div class="layui-input-inline">
                    <input type="text" name="Contact1" lay-verify="required" placeholder="请输入联系人1" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" style="width:auto">联系人1-电话</label>
                <div class="layui-input-inline">
                    <input type="text" name="Contact1Tel" lay-verify="required" placeholder="请输入联系人1-电话" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" style="width:auto">联系人1-邮箱</label>
                <div class="layui-input-inline">
                    <input type="text" name="Contact1Email" lay-verify="required" placeholder="请输入联系人1-邮箱" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">联系人2</label>
                <div class="layui-input-inline">
                    <input type="text" name="Contact2" lay-verify="required" placeholder="请输入联系人2" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" style="width:auto">联系人2-电话</label>
                <div class="layui-input-inline">
                    <input type="text" name="Contact2Tel" lay-verify="required" placeholder="请输入联系人2-电话" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" style="width:auto">联系人2-邮箱</label>
                <div class="layui-input-inline">
                    <input type="text" name="Contact2Email" lay-verify="required" placeholder="请输入联系人2-邮箱" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label" style="width:auto">社会信用代码</label>
                <div class="layui-input-inline">
                    <input type="text" name="CreditCode" lay-verify="required" placeholder="请输入社会信用代码" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea name="Remark" placeholder="请输入内容" class="layui-textarea"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit lay-filter="demo1">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
    <!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
    <script src="~/Scripts/jquery-3.4.1.min.js"></script>
    <script src="//unpkg.com/layui@2.9.17/dist/layui.js"></script>

    <script>
        layui.use(['form', 'laydate', 'util'], function () {
            var form = layui.form;
            var layer = layui.layer;
            var laydate = layui.laydate;
            var util = layui.util;

            // 自定义验证规则
            // form.verify({
            //     pass: function (value) {
            //         if (!/(.+){6,12}$/.test(value)) {
            //             return '密码必须 6 到 12 位';
            //         }
            //     }
            // });

            // 提交事件
            form.on('submit(demo1)', function (data) {
                var field = data.field; // 获取表单字段值
                // 显示填写结果，仅作演示用
                // layer.alert(JSON.stringify(field), {
                //     title: '当前填写的字段值'
                // });
                // 此处可执行 Ajax 等操作
                // …
                $.get('/MainData/AddClient', field, function (res) {
                    if (res > 0) {
                        layer.msg('保存成功', {
                            icon: 1,
                            time: 500
                        }, function () {
                            var index = parent.layer.getFrameIndex(window.name);//先得到当前iframe层的索引
                            parent.layer.close(index);//再执行关闭
                        });
                    } else {
                        layer.msg("网络异常");
                    }
                });
                return false; // 阻止默认 form 跳转
            });

            // 日期
            // laydate.render({
            //     elem: '#date'
            // });

            // 普通事件
            // util.on('lay-on', {
            //     // 获取验证码
            //     "get-vercode": function (othis) {
            //         var isvalid = form.validate('.demo-phone'); // 主动触发验证，v2.7.0 新增
            //         // 验证通过
            //         if (isvalid) {
            //             layer.msg('手机号规则验证通过');
            //             // 此处可继续书写「发送验证码」等后续逻辑
            //             // …
            //         }
            //     }
            // });
        });
    </script>

</body>
</html>